package com.platform.controller.platform;

import com.platform.common.annotation.Log;
import com.platform.common.core.domain.AjaxResult;
import com.platform.common.core.page.TableDataInfo;
import com.platform.common.enums.BusinessType;
import com.platform.common.enums.ResultEnum;
import com.platform.common.exception.BusinessException;
import com.platform.system.domain.dto.device.SpeakerInfoDto;
import com.platform.system.domain.vo.device.DeviceLogVo;
import com.platform.system.domain.vo.device.ModelAppInfoVo;
import com.platform.system.domain.vo.device.SpeakerInfoVo;
import com.platform.system.service.ISysDeviceLogService;
import com.platform.system.service.ISysSpeakerInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author Huangkai
 */
@Slf4j
@RestController
@RequestMapping("/speakerInfo/config")
public class SpeakerInfoController {

    @Resource
    ISysSpeakerInfoService sysSpeakerInfoService;

    /**
     * 查询发音人
     */
    @Log(title = "查询发音人", businessType = BusinessType.OTHER)
    @GetMapping("/selectSpeakerInfoList")
    public TableDataInfo selectSpeakerInfoList(@Validated SpeakerInfoVo speakerInfoVo) {
        return sysSpeakerInfoService.selectSpeakerInfoList(speakerInfoVo);
    }

    @Log(title = "查询详情", businessType = BusinessType.OTHER)
    @GetMapping("/selectSpeakerInfo/{uid}")
    public AjaxResult selectSpeakerInfo(@PathVariable(value = "uid") String uid) {
        SpeakerInfoDto speakerInfoDto = sysSpeakerInfoService.selectSpeakerInfo(uid);
        if(speakerInfoDto == null){
            throw new BusinessException(ResultEnum.DATA_NOT_EXIST);
        }
        return AjaxResult.success(speakerInfoDto);
    }

    /**
     * 新增
     */
    @Log(title = "新增发音人", businessType = BusinessType.INSERT)
    @PostMapping("/insertSpeakerInfo")
    public AjaxResult insertSpeakerInfo(@RequestBody @Validated SpeakerInfoVo speakerInfoVo) {
        return sysSpeakerInfoService.insertSpeakerInfo(speakerInfoVo);
    }
    /**
     * 修改状态
     */
    @Log(title = "修改状态", businessType = BusinessType.UPDATE)
    @PostMapping("/updateSpeakerInfoStatus")
    public AjaxResult updateSpeakerInfoStatus(@RequestBody @Validated SpeakerInfoVo speakerInfoVo) {
        return sysSpeakerInfoService.updateSpeakerInfoStatus(speakerInfoVo);
    }

    /**
     * 删除
     */
    @Log(title = "删除", businessType = BusinessType.DELETE)
    @PostMapping("/deleteSpeakerInfo")
    public AjaxResult deleteSpeakerInfo(@RequestBody @Validated SpeakerInfoVo speakerInfoVo) {
        return sysSpeakerInfoService.deleteSpeakerInfo(speakerInfoVo);
    }

    /**
     * 修改
     */
    @Log(title = "修改", businessType = BusinessType.UPDATE)
    @PostMapping("/updateSpeakerInfo")
    public AjaxResult updateSpeakerInfo(@RequestBody @Validated SpeakerInfoVo speakerInfoVo) {
        return sysSpeakerInfoService.updateSpeakerInfo(speakerInfoVo);
    }

}
